package com.example.airobotinterviewrecord.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum SendEmailEnum {
    NOT_SEND(0, "否"),
    SEND(1, "是");

    @EnumValue  // 标记存入数据库的字段
    private final int code;
    private final String desc;

    SendEmailEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 根据code获取枚举
    public static SendEmailEnum fromCode(int code) {
        for (SendEmailEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的发送状态编码: " + code);
    }
    @JsonValue
    public String getDesc() {
        return desc;
    }
}
